<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>X-admin v1.0</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/woniu/Public/X-admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" method="post">
					
                <input type="hidden" name="id" value="<?php echo ($list['id']); ?>">
				<input type="hidden" name="classid" value="<?php echo ($list['class']); ?>">

                <div class="layui-form-item">
                    <label for="username" style="font-size:24px" >事假申请单</label>
                </div>

				<div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>申请人
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" disabled id="username" name="name" value="<?php echo ($list['name']); ?>" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

			    <div class="layui-form-item">
			        <label class="layui-form-label">起始日期</label>
			          <div class="layui-input-inline">
	                    <input class="layui-input" name="start_time" placeholder="yyyy-yy-yy" required="" lay-verify="required" autocomplete="off" id="LAY_demorange_s">
			        </div>
			    </div>

			    <div class="layui-form-item">
			        <label class="layui-form-label">终止日期</label>
			          <div class="layui-input-inline">
	                    <input class="layui-input" name="end_time" placeholder="yyyy-yy-yy" required="" lay-verify="required" autocomplete="off" id="LAY_demorange_e">
			        </div>
			    </div>

			    <div class="layui-form-item layui-form-text">
		          <label class="layui-form-label">事假原因</label>
		          <div class="layui-input-block">
		            <textarea name="cause" id="cause" placeholder="请输入内容" class="layui-textarea"></textarea>
		          </div>
		        </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="">确认修改</button>
                </div>
            </form>
        </div>
        <script src="/woniu/Public/X-admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="/woniu/Public/X-admin/js/x-layui.js" charset="utf-8">
        </script>
        
        <script>

            layui.use(['laydate','element','laypage','layer','form'], function(){
                $ = layui.jquery;//jquery
              laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层
              form = layui.form(); 
            	
              var start = {
                min: laydate.now()
                ,max: '2099-06-16 23:59:59'
                ,istoday: false
                ,choose: function(datas){
                  end.min = datas; //开始日选好后，重置结束日的最小日期
                  end.start = datas //将结束日的初始值设定为开始日
                }
              };
              
              var end = {
                min: laydate.now()
                ,max: '2099-06-16 23:59:59'
                ,istoday: false
                ,choose: function(datas){
                  start.max = datas; //结束日选好后，重置开始日的最大日期
                }
              };

              document.getElementById('LAY_demorange_s').onclick = function(){
                start.elem = this;
                laydate(start);
              }
              document.getElementById('LAY_demorange_e').onclick = function(){
                end.elem = this
                laydate(end);
              };

              //监听提交
              form.on('submit(add)', function(data){
                //发异步，把数据提交给php
                ids = $("input[name='id']").val();
                classid = $("input[name='classid']").val();
                name = $("input[name='name']").val();
                date1 = new Date($("input[name='start_time']").val());
                start_time = date1.getTime();
                date2 = new Date($("input[name='end_time']").val());
                end_time = date2.getTime();
                cause = $("#cause").val();

                $.post('/woniu/index.php/Home/Leave/insert',{id:ids,classid:classid,name:name,start_time:start_time,end_time:end_time,cause:cause},function(data){
                    if(data=="失败"){
                    	alert(data);
                    }
                });
                layer.alert("添加成功", {icon: 6},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    parent.reload();
                });
                return false;

            });
          });

              

        </script>
    </body>

</html>